home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-M68K / VIRTCONV.{2U < prev   
Text File  |  1999-09-17  |  2KB  |  77 lines

  1. #ifndef __VIRT_CONVERT__
  2. #define __VIRT_CONVERT__
  3.  
  4. /*
  5.  * Macros used for converting between virtual and physical mappings.
  6.  */
  7.  
  8. #ifdef __KERNEL__
  9.  
  10. #include <linux/config.h>
  11. #include <asm/setup.h>
  12.  
  13. #ifdef CONFIG_AMIGA
  14. #include <asm/amigahw.h>
  15. #endif
  16.  
  17. /*
  18.  * Change virtual addresses to physical addresses and vv.
  19.  */
  20. extern unsigned long mm_vtop(unsigned long addr) __attribute__ ((const));
  21. extern unsigned long mm_vtop_fallback (unsigned long) __attribute__ ((const));
  22. extern unsigned long mm_ptov(unsigned long addr) __attribute__ ((const));
  23.  
  24. #ifdef CONFIG_SINGLE_MEMORY_CHUNK
  25. extern inline unsigned long virt_to_phys(volatile void * address)
  26. {
  27.     unsigned long voff = (unsigned long) address;
  28.  
  29.     if (voff < m68k_memory[0].size)
  30.         return m68k_memory[0].addr + voff;
  31.     else
  32.         return mm_vtop_fallback(voff);
  33. }
  34.  
  35. extern inline void * phys_to_virt(unsigned long paddr)
  36. {
  37.     unsigned long base = m68k_memory[0].addr;
  38.  
  39.     if ((paddr >=  base) && (paddr < (base + m68k_memory[0].size)))
  40.         return (void *)(paddr - base);
  41. #ifdef CONFIG_AMIGA
  42.     /*
  43.      * if on an amiga and address is in first 16M, move it 
  44.      * to the ZTWO_VADDR range
  45.      */
  46.     if (MACH_IS_AMIGA && paddr < 16*1024*1024)
  47.         return (void *)ZTWO_VADDR(paddr);
  48. #endif
  49.     return (void *)paddr;
  50. }
  51. #else
  52. extern inline unsigned long virt_to_phys(volatile void * address)
  53. {
  54.     return mm_vtop((unsigned long)address);
  55. }
  56.  
  57. extern inline void * phys_to_virt(unsigned long address)
  58. {
  59.     return (void *) mm_ptov(address);
  60. }
  61. #endif
  62.  
  63. /*
  64.  * IO bus memory addresses are 1:1 with the physical address,
  65.  * except on the PCI bus of the Hades.
  66.  */
  67. #ifdef CONFIG_HADES
  68. #define virt_to_bus(a) (virt_to_phys(a) + (MACH_IS_HADES ? 0x80000000 : 0))
  69. #define bus_to_virt(a) (phys_to_virt((a) - (MACH_IS_HADES ? 0x80000000 : 0)))
  70. #else
  71. #define virt_to_bus virt_to_phys
  72. #define bus_to_virt phys_to_virt
  73. #endif
  74.  
  75. #endif
  76. #endif
  77.